﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace csexplorer
{
    public partial class CsExplorerFrm : Form
    {
        private CsExplorerManager explorerMgr;

        public CsExplorerFrm()
        {
            InitializeComponent();
            explorerMgr = new CsExplorerManager();
            treeViewExplorer1.ExplorerMgr = explorerMgr;
            listViewExplorer1.ExplorerMgr = explorerMgr;
        }

        private void menuItemClose_Click(object sender, EventArgs e)
        {
            //quit application
            this.Close();
        }

        private void treeViewExplorer1_FileSelected(object sender, csexplorer.UserControls.FileSelectedArg e)
        {
            if (e.DiskEntity is DirectoryInformation)
            {
                listViewExplorer1.LoadDirectoryContent(e.DiskEntity as DirectoryInformation);
            }

            if (e.DiskEntity is FileInformation)
            {
                string fileName = System.IO.Path.Combine(e.DiskEntity.Path, e.DiskEntity.Name);

                Icon smalIcon = null;
                Icon largeIcon = null;
                HelperFunctions.GetIcon(fileName, out smalIcon, out largeIcon);

                if (smalIcon != null && largeIcon != null)
                {
                    imageList1.Images.Clear();
                    imageList1.Images.Add(smalIcon);
                    pictureBox1.Image = imageList1.Images[0];
                }
            }
        }
    }
}
